Indirect Reference to Variables

You can also make indirect references to variables. An indirect reference is made by prefixing the variable name with an exclamation mark. For example, a simple command like @Clear Grade would clear the attribute (variable) called Grade. However, you can also do this:

@Assign S = 'Grade'

@Clear !S

This @Clear command would also clear the variable called Grade and not the variable called S as the exclamation mark denotes this as an indirect reference. Both variables must still be defined in the Knowledge Explorer in the normal way, and any string type variables can be used (List attribute, string array, etc.) to hold indirect references.

It is strongly recommended that you use enhanced syntax, which is to enclose the indirect reference in brackets, as standard practice. This is required when using arrays (as the examples below show) and when using properties.

Example 1

@ASSIGN S = 'Grade.default'
@DEBUG !(S) 

The use of brackets avoids any problems of ambiguity about the name(s) being treated as two variables called Grade and default or the correct property name called Grade.default.

Example 2

@ASSIGN stringArr[1,2] = 'Hello World!'
@ASSIGN direfStr = 'stringArr[1,2]'
@DEBUG !(direfStr)

The above debug statement would print "Hello World!" (the contents of stringArr[1,2])

Example 3

@ASSIGN stringArr[1,2] = 'Hello World!'
@ASSIGN direfStr = 'stringArr'
@DEBUG !(direfStr)[1,2]

The above debug statement would print "Hello World!" (the contents of stringArr[1,2]) As you can see, the !(derefStr) part has been replaced by stringArray which is then index by the [1,2] part.

Indirect Variable Referencing is not supported by VBScript in XpertRule.